package com.surekam;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class customAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private List<String[]> list;
    public customAdapter(LayoutInflater inflater, 
	    List<String[]> list) {
	this.inflater = inflater;
	this.list = list;  
    }	


    public int getCount() {
	// TODO Auto-generated method stub
	return list.size();
    }


    public Object getItem(int position) {
	// TODO Auto-generated method stub
	return list.get(position);
    }

    public long getItemId(int position) {
	// TODO Auto-generated method stub
	return position;
    }

 
    public View getView(int position,
	    View convertView, ViewGroup parent) {
	View view;
	if(convertView==null){
	   view = inflater.inflate(R.layout.list_item, null);
	}else {
	    view = convertView;
	}
	final Button btn1= (Button)view.findViewById(R.id.button1);
	TextView tv = (TextView)view.findViewById(R.id.textView1);
	TextView tv1 = (TextView)view.findViewById(R.id.textView2);
	TextView tv2 = (TextView)view.findViewById(R.id.textView3);
	tv.setText(list.get(position)[0]);
	tv1.setText(list.get(position)[1]);
	tv2.setText(list.get(position)[2]);
	//btn1.setText(list.get(position)[3]);
	btn1.setOnClickListener(new OnClickListener() {
	    
	   public void onClick(View v) {
		Toast.makeText(inflater.getContext(), btn1.getText(), 2000).show();
	    }
	});
	
	return view;
    }

}
